package com.huyanqi.front.rest.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.huyanqi.core.RetdCodeType;
import com.huyanqi.core.RetdObj;
import com.huyanqi.core.service.impl.BaseFrontServiceImpl;
import com.huyanqi.dao.CourseDAO;
import com.huyanqi.dao.UserDAO;
import com.huyanqi.entity.Course;
import com.huyanqi.front.rest.service.CourseRestService;

@Service("CourseRestService")
public class CourseRestImpl extends BaseFrontServiceImpl<Course,Long, CourseDAO> implements CourseRestService{

	@Override
	@Resource(name="CourseDAO")
	public void setEntityDao(CourseDAO entityDao) {
		this.entityDao=entityDao;
	}
	
	private UserDAO userDao;
	@Resource(name="UserDAO")
	public void setUserDao(UserDAO userDao) {
		this.userDao = userDao;
	}

	@Override
	public RetdObj<List<Course>> findCourseByCsid(Long diyid) {
		RetdObj<List<Course>> retd = new RetdObj<List<Course>>();
		try{
			List<Course> list = entityDao.executeQuery("FROM Course WHERE csDiyid = ? ORDER BY csStep ASC", diyid);
			if(list.size()>0){
				retd.setRealObj(list);
				retd.setCode(RetdCodeType.PASS_OK);
			}else{
				retd.setCode(RetdCodeType.PASS_NODATA);
			}
		}catch (Exception e) {
			e.printStackTrace();
			retd.setCode(RetdCodeType.EX_APP);
		}
		return retd;
	}

}
